/*
 *  Class name: TeamRestClient.java
 *  Version: 1.0
 *  Date: 15.12.2013
 */
package cz.muni.fi.pa165.soccergamesarchive.restclient.rest.entity;

import cz.muni.fi.pa165.soccergamesarchive.businesslayer.dtos.TeamDTO;
import cz.muni.fi.pa165.soccergamesarchive.restclient.rest.EntityRestClient;
import java.util.List;
import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.MediaType;

import static javax.ws.rs.client.Entity.entity;

/**
 *
 * @author Michal Ďuriš
 */
public class TeamRestClient extends EntityRestClient<TeamDTO> {

    private static final String SHIRT_NUMBERS_OPERATION_PATH = "availnumbers";

    public TeamRestClient() {
        super(TeamDTO.class);
    }

    @Override
    protected String getEntityPath() {
        return "team";
    }

    @Override
    protected GenericType<List<TeamDTO>> getGenericEntityTypeList() {
        return new GenericType<List<TeamDTO>>() {
        };
    }

    public List<Integer> getAvailableShirtNumbers(TeamDTO team) throws
            RuntimeException {

        return restClientTargetResource.path(SHIRT_NUMBERS_OPERATION_PATH)
                .request(
                        MediaType.TEXT_XML).post(entity(team,
                                MediaType.TEXT_XML),
                        new GenericType<List<Integer>>() {
                        });
    }

}
